package com.gaswell.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gaswell.common.log.LogAnnotation;
import com.gaswell.entity.Qba01;
import com.gaswell.pojo.KSParaDatas;
import com.gaswell.service.KSParaDatasService;
import com.gaswell.service.UserService;
import com.gaswell.vo.JHVo;
import com.gaswell.vo.Result;
import com.gaswell.vo.RtuDataVo;
import io.jsonwebtoken.lang.Collections;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @ClassName KSYmCurveController
 * @Author xiaow
 * @DATE 2023/2/21 15:32
 **/


@RestController
@RequestMapping("/ksparadatas")
@Api(tags = "ksparadatas 前端控制器   mysql数据库")
public class KSParaDatasController {

    @Autowired
    private KSParaDatasService ksParaDatasService;
    @Autowired
    UserService userService;


    @PostMapping("/pageByJhAndTime")
    @ApiOperation(value = "根据时间段和井号查询过往数据    时间格式  yyyy-MM-dd HH:mm:ss")
    @LogAnnotation(module = "根据时间段和井号查询过往数据", operator = "根据时间段和井号查询过往数据")
    public Result pageByJhAndTime(String userName, int current, int size, String start, String end, @RequestBody JHVo jhVo) {
        int department = userService.selectUserByuserName(userName).getUser_department_id();

        Page<KSParaDatas> page = new Page<>(current, size);
//        List jh_list = Collections.arrayToList(jhVo.getJhs());
        Page<KSParaDatas> ksParaDatasPage = ksParaDatasService.pageByJhAndTime(page, jhVo.getJhs(), start, end, department);
        return new Result(true, 200, "success", ksParaDatasPage.getRecords(), (int) ksParaDatasPage.getTotal(), (int) ksParaDatasPage.getPages());
    }

}
